package com.fishingwithme.domain.circle;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import com.fishingwithme.infrastructure.dtos.anybiting.BaseCircleMessageDto;

@Component
public class CircleRedisMessagePublisher {
    private final RedisTemplate<String, Object> redisTemplate;

    public CircleRedisMessagePublisher(@Qualifier("circleRedisMsgTemplate") RedisTemplate<String, Object> redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    public void publish(String channel, BaseCircleMessageDto message) {
        try {
            redisTemplate.convertAndSend(channel, message);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
